All Questions
Tagged with functional-programmingalgorithm
81 questions
3votes
2answers
185views
Map coloring algorithm functional implementation in python
I'm an autodidact working on map coloring algorithms with backtracking, see chapter 2 of this book. I tested this implementation with success but I'm still unsure whether it is tricking me somewhere, ...
2votes
1answer
108views
Move timestamp to the next Monday 10:01 AM [closed]
I've been battling ChatGPT for hours now and can't get satisfied with this simple algorithm in TypeScript. These two (hopefully correct) TypeScript+ReactNative solutions should move the timestamp ...
3votes
1answer
134views
1vote
2answers
610views
Removing Elements from an Array Based on a Second Array
I've written a function that takes two arrays of integers as input and removes all the elements in the first array that are also present in the second array. I would like to share my code with you and ...
1vote
1answer
58views
Optimizing the Dig Pow function
I have written a Python function to solve the Dig Pow problem, where the goal is to find a number k such that the sum of each digit of n raised to a specific and ...
7votes
5answers
1kviews
Optimizing a function to find the closest multiple of 10
I have written a Python function called closest_multiple_10() which takes an integer as input and returns the closest multiple of 10. The function works as expected,...
4votes
7answers
279views
Breaking a string expression in operator and operands
Requesting for a code review for a scala implementation. Problem Given an expression string made of numbers and operators +,-,/,* , break it in a list of Integer or ...
2votes
1answer
135views
Project Euler 11 Haskell - Largest product in a grid
Intro I have been learning haskell and functional programming using random Project Euler problems. Currently, I have solved Problem 11. What is the greatest product of four adjacent numbers in the ...
1vote
1answer
830views
Functional Fibonacci in OCaml
I'm very new to OCaml, and as an exercise I decided to implement the nth Fibonacci algorithm (return a specific Fibonacci number, given an index) in different ways, using what I've learned so far. I ...
2votes
3answers
124views
Is My Function to Find Triplets in Scala running in O(N^2)
Given the classical problem to find triplets that sum to zero in an array. Is my Scala implementation correct and executed in O(N^2)? If yes, why? Can someone make a running time analysis. What other ...
4votes
3answers
2kviews
Split function using C and dynamic memory allocation
I have programmed a function to split strings, and it gives the expected output. I am looking forward to write better code and I was told here is a good place to start. Here's my program: ...
2votes
1answer
125views
Projecteuler.net Problem 2 using collection pipeline Pattern
I solve projecteuler.net Problem 2 deferent way Generate number from 1 to range ex 100 and get the even number Get Fibonacci numbers from list Reduce array I have one problem with a large set of ...
3votes
2answers
4kviews
Hackerrank problem: Climbing the Leaderboard (Java)
I am solving the following Hackerrank problem: Climbing the Leaderboard. The problem statement: Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ...
3votes
1answer
224views
C++ algorithm to implement multiple operators in one
I have a class called IntMatrix which has 2 fields: ...
2votes
1answer
89views
naive bayes sentiment analysis classifier in clojure
attaching my try on implementing simple naive-bayes classifier for sentiment analysis as part of learning clojure and using functional programming on ML algorithms. I tried to invest more time in ...